package fybug.nulll.pdstream.WR.Parsing;
import com.sun.istack.internal.NotNull;

import java.io.InputStream;
import java.io.Reader;

import fybug.nulll.pdfunctionlibrary.Processing.ConsistentField;
import fybug.nulll.pdfunctionlibrary.lang.Interface.Cleanable;
import fybug.nulll.pdstream.WR.Err.CharStreamErr;
import fybug.nulll.pdstream.WR.Parsing.Interface.StringResolve;
import fybug.nulll.pdstream.WR.Parsing.Source.ParsingSource;
import fybug.nulll.pdstream.WR.Parsing.Source.Partition.ParsingPartition;
/**
 * <h2>文本解析器.</h2>
 * <pre>
 * 使用一个 <b>解析源</b> 获取数据
 * 用于 <b>解析文本</b> ，需传入 <b>监听接口和解析源</b>
 * 否则将会是 <b>空解析</b>
 *
 * 可用于并发,但不建议
 * </pre>
 *
 * @author fybug
 * @version 0.0.8
 * @see Cleanable
 * @see StringParsingS
 * @see ConsistentField
 * @since JDK 1.8
 */
@SuppressWarnings( "All" )
public abstract
class StringParsingBoot extends ConsistentField implements Cleanable {
    @Override
    public
    int hashCode()
    { return (getClass().hashCode() + super.hashCode()) << 5; }

    /**
     * <p>绑定解析源.</p>
     * <pre>
     * 绑定要进行解析的数据来源
     * 如果没有绑定则不会进行解析
     * </pre>
     *
     * @param soure 解析数据源
     *
     * @see ParsingSource
     */
    @NotNull
    public abstract
    StringParsingBoot binSoure(@NotNull final ParsingSource soure);

    /** <p>获取绑定的解析源.</p> */
    @NotNull
    public abstract
    ParsingSource soure();

    /** <p>对接解析源的数据绑定接口.</p> */
    @NotNull
    public abstract
    StringParsingBoot binReader(@NotNull final Reader reader);

    /** <p>对接解析源的数据绑定接口.</p> */
    @NotNull
    public abstract
    StringParsingBoot binReader(@NotNull final InputStream inputStream);

    /** <p>对接解析源的数据绑定接口.</p> */
    @NotNull
    public abstract
    StringParsingBoot binReader(@NotNull final CharSequence charSequence);

    /** <p>对接解析源的分割器绑定接口.</p> */
    @NotNull
    public abstract
    StringParsingBoot binPartition(@NotNull final ParsingPartition r);

    /**
     * <p>开始解析.</p>
     *
     * @param resolve 调用该接口进行解析和返回解析数量<br/>
     *                如没有则为 <b>空解析</b>
     *
     * @throws CharStreamErr {@link ParsingSource#get()}
     */
    @NotNull
    public abstract
    StringParsingBoot parsing(@NotNull final StringResolve resolve) throws CharStreamErr;
}
